<?php

namespace App\Console\Commands;

use App\Console\Base;
use App\Models\PayVendorScene;
use App\Models\BankReceiveAccount;

use Illuminate\Support\Facades\DB;

class ClearDayData extends Base
{
    /**
     * 控制台命令 signature 的名称。
     *
     * @var string
     */
    protected $signature = self::PREFIX . 'cleardaydata';

    /**
     * 控制台命令说明。
     *
     * @var string
     */
    protected $description = '用于每天凌晨清除数据';

    /**
     * 执行控制台命令。
     *
     * @return mixed
     */
    public function handle()
    {
        //清除充值渠道表(pay_vendor_scene)的当日入款总额
        $ret = PayVendorScene::where('day_amount', '>', 0)->update(['day_amount' => 0]);
        if($ret === false){
            $this->error("清除充值渠道表(pay_vendor_scene)的当日入款总额失败");
        }
        $this->info("清除充值渠道表(pay_vendor_scene)的当日入款总额成功");
        //清除公司存款账户(bank_receive_account)的当日入款总额
        $ret = BankReceiveAccount::where('day_amount', '>', 0)->update(['day_amount' => 0]);
        if($ret === false){
            $this->error("清除公司存款账户(bank_receive_account)的当日入款总额失败");
        }
        $this->info("清除公司存款账户(bank_receive_account)的当日入款总额成功");
        return true;
    }

}
